package components;

import com.uqbar.vainilla.DeltaState;
import com.uqbar.vainilla.GameComponent;
import com.uqbar.vainilla.appearances.Appearance;
import com.uqbar.vainilla.colissions.CollisionDetector;
import com.uqbar.vainilla.events.constants.MouseButton;

public class ClickeableComponent extends GameComponent {

	private int width;
	private int height;

	
	public ClickeableComponent(double x, double y, Appearance appearance, int width, int height){
		super(x, y);
		this.setZ(5);
		this.width = width;
		this.height = height;
		this.setAppearance(appearance);
		
	}
	
	public void onLeftClick(){
		
	}
	
	public void update(DeltaState delta){
		if (delta.isMouseButtonReleased(MouseButton.LEFT)){
			if (CollisionDetector.INSTANCE.collidesRectAgainstRect(this.getX(),
					this.getY(), width, height, delta.getCurrentMousePosition().x, delta.getCurrentMousePosition().y, 1, 2)){
				
				this.onLeftClick();
			}
		}
	}
}
